package com.wolf.cx330.view.view

import android.content.Context
import android.graphics.Canvas
import android.graphics.Paint
import android.graphics.Point
import android.util.AttributeSet
import android.view.View
import androidx.core.content.ContextCompat
import com.wolf.cx330.R
import com.wolf.cx330.base.dp

class PointView(context: Context, attributeSet: AttributeSet) : View(context, attributeSet) {
    private val paint = Paint().apply {
        color = ContextCompat.getColor(context, R.color.colorPrimary)
        strokeWidth = 20F.dp()
        style = Paint.Style.FILL
        strokeCap = Paint.Cap.ROUND
    }
    var point: Point = Point()
        set(value) {
            field = value
            invalidate()
        }

    override fun onDraw(canvas: Canvas) {
        super.onDraw(canvas)
        canvas.drawPoint(point.x.toFloat(), point.y.toFloat(), paint)
    }
}